#include <stdio.h>
#include <stdlib.h>

int main() {
	
	FILE *data, *summary;
	int line = 0, lower = 0, upper = 0, digits = 0, other = 0;
	char ch;

	data = fopen("data.txt","r");
	if(data == NULL){
		printf("Error");
		exit(1);
	}
	
	summary = fopen("summary.txt","a");
	
	while(fscanf(data, "%c", &ch) != EOF){
		
		if(ch=='\n')
		line++;
	else if(ch>='a' && ch<='z')
		lower++;
	else if(ch>='A' && ch<='Z')
		upper++;
	else if(ch>='0' && ch<='9')
		digits++;
	else other++;		
	
		}
	fprintf(summary,"Nmber of line = %d\nNumber of lowercase letters = %d\nNumber of uppercase letters = %d\nNumber of digits = %d\nNumber of other characters = %d",line, lower, upper, digits, other);
	
	fclose (data);
	fclose (summary);
	return 0;
}
